# Maintainer: kpcyrd <kpcyrd[at]archlinux[dot]org>
# Maintainer: Orhun Parmaksız <orhun@archlinux.org>

pkgname=dog
pkgver=0.1.0
pkgrel=4
pkgdesc='Command-line DNS client like dig'
url='https://github.com/ogham/dog'
arch=('loong64' 'x86_64')
license=('custom:EUPL')
replaces=('dog-dns')
depends=('openssl' 'gcc-libs')
makedepends=('cargo')
source=("https://github.com/ogham/${pkgname}/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz"
        "$pkgname-$pkgver-man.1"
         dog-openssl-crates-update.patch)
b2sums=('7ea52027e73deb6db6cb67b89063cddd507246256b3ca93479a634ff6696ab6961f004da8272b4c535067868603d8218b44c3696e34b5126371a9e0d5fc36058'
        '96260ac3d6b5e16e097877538213ff983e5d1f932d695410664234b1b0eeed3c30d4ca27c79fc9da675e2b3a8f192a8e660628454458545dcdde9ff984548483'
        '2e07323f9ad08f804921edf03ff4bbe72a4d25138dfc7d932974ce61ad01ede88bbf04b32a864201fb4b539e7d61850e29b8c536b859dc4f1785039a6d8da64a')

prepare() {
  cd ${pkgname}-${pkgver}
  patch -Np1 -i ../dog-openssl-crates-update.patch
  cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
}

build() {
  cd ${pkgname}-${pkgver}
  cargo build --release --frozen
}

check() {
  cd ${pkgname}-${pkgver}
  cargo test --release --frozen
}

package() {
  cd ${pkgname}-${pkgver}
  install -Dm 755 target/release/${pkgname} -t "${pkgdir}/usr/bin"

  install -Dm 644 completions/${pkgname}.bash "${pkgdir}/usr/share/bash-completion/completions/${pkgname}"
  install -Dm 644 completions/${pkgname}.fish -t "${pkgdir}/usr/share/fish/completions"
  install -Dm 644 completions/${pkgname}.zsh "${pkgdir}/usr/share/zsh/site-functions/_${pkgname}"

  install -Dm 644 README.md -t "${pkgdir}/usr/share/doc/${pkgname}"
  install -Dm 644 LICENCE -t "${pkgdir}/usr/share/licenses/${pkgname}"

  install -Dm 644 "$srcdir/$pkgname-$pkgver-man.1" "$pkgdir/usr/share/man/man1/$pkgname.1"
}

# vim: ts=2 sw=2 et:
